package com.ruoyi.qd.enums;

import com.google.common.collect.ImmutableList;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum TradeWaterTypeEnum {
    WALLET_RECHARGE("10", "钱包充值", true),
    PERSONAL_CANCEL_APPOINTMENT_ROBOT_REFUND("11", "自己取消预约单退款", true),
    SYSTEM_CANCEL_APPOINTMENT_ROBOT_REFUND("12", "后台取消预约单退款", true),
    PASS_NUMBER_REFUND("13", "过号退款", true),
    APPOINTMENT_ROBOT_PAYMENT("60", "预约机器人支付", false),
    ;

    private final String code;
    private final String info;

    // true: 正向流水  false: 负向流水
    private final Boolean positiveFlag;

    // 正向流水集合
    public static final ImmutableList<String> POSITIVE_CODE_LIST;
    // 负向流水集合
    public static final ImmutableList<String> NEGATIVE_CODE_LIST;
    static {
        ImmutableList.Builder<String> positiveBuilder = ImmutableList.builder();
        ImmutableList.Builder<String> negativeBuilder = ImmutableList.builder();
        for (TradeWaterTypeEnum tradeWaterTypeEnum : TradeWaterTypeEnum.values()) {
            if (tradeWaterTypeEnum.positiveFlag) {
                positiveBuilder.add(tradeWaterTypeEnum.getCode());
            } else {
                negativeBuilder.add(tradeWaterTypeEnum.getCode());
            }
        }
        POSITIVE_CODE_LIST = positiveBuilder.build();
        NEGATIVE_CODE_LIST = negativeBuilder.build();
    }

    public static String getInfoByCode(String code) {
        for (TradeWaterTypeEnum tradeWaterTypeEnum : TradeWaterTypeEnum.values()) {
            if (tradeWaterTypeEnum.getCode().equals(code)) {
                return tradeWaterTypeEnum.getInfo();
            }
        }
        return null;
    }
}
